﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DOTNETGROUP.Entities;
using DOTNETGROUP.Data;
using System.Text;

public partial class Controls_ControlSlide : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            hienThiDichVu();
        }
    }

    // Method: Hiển thị thông tin dịch vụ
    // Input: N/A
    // Output: void
    public void hienThiDichVu()
    {
        // Khởi tạo
        int TotalRows = 0;
        string WhereClause = "1=1 and TrangThai=1";
        
        // Lấy 5 tin dịch vụ
        TList<DichVu> lstDichVu = DataRepository.DichVuProvider.GetPaged(WhereClause, "NgayCapNhat DESC", 0, 5, out TotalRows);
        
        if (lstDichVu.Count > 0)
        {
            string strHTML = "";

            for (int i = 0; i < lstDichVu.Count; i++)
            {
                strHTML += "<li>";

                strHTML += "<img src='" + ResolveUrl("../Upload/AnhDaiDien/" + lstDichVu[i].AnhDaiDien) + "'/>";

                strHTML += "<div class='caption'>";

                strHTML += "<div class='caption-box'>";
                strHTML += "<a href='" + ResolveUrl("../DichVu/"+ GetTieuDe(lstDichVu[i].TenDichVu) + "_" + lstDichVu[i].Id + ".aspx") + "' class='caption-title'>" + lstDichVu[i].TenDichVu + "</a>";
                strHTML += "<p class='description'>" + lstDichVu[i].TomTat + "</p>";
                strHTML += "</div>";

                strHTML += "</div>";

                strHTML += "</li>";
            }

            

            ltrDichVu.Text = strHTML;
        }
    }

    public string GetTieuDe(object Char)
    {
        string s = Char.ToString();
        return Common.ConvertToUnSign(s);
    }
}